public class test02 {
    /**
     * Definition for a binary tree node.
     * public class TreeNode {
     *     int val;
     *     TreeNode left;
     *     TreeNode right;
     *     TreeNode() {}
     *     TreeNode(int val) { this.val = val; }
     *     TreeNode(int val, TreeNode left, TreeNode right) {
     *         this.val = val;
     *         this.left = left;
     *         this.right = right;
     *     }
     * }
     */
        public boolean isSymmetric(TreeNode root) {
            if(root==null){
                return true;
            }
            return recursion(root.left,root.right);
        }
        private boolean recursion(TreeNode root1,TreeNode root2){
            if(root1==null && root2==null){
                return true;
            }else if(root1==null || root2==null){
                return false;
            }else if(root1.val!=root2.val){
                return false;
            }
            boolean b1 = recursion(root1.left,root2.right);
            boolean b2 = recursion(root1.right,root2.left);
            return b1&&b2;
        }
}
